layui.use('element', function(){
		var $ = layui.jquery,
		element = layui.element();
	});

var app = new Vue({
				el: '#app',
				data: {
					user:'',
					apiUrl: '/api/me'
				   ,postUrl: '/user/haha'
				   ,user:{
				      name:'haha',
				      old:'1'
				   }
				},
				created: function() {
//				    console.log("token-expired:"+keter.getItem("token-expired"));
				    console.log("距离token过期还有:"+ keter.tokenExpiredRemainSeconds()+"秒");
				    // 查询当前用户id
				    keter.get(this, this.apiUrl).then(function (res) {
				        console.log("userid:"+res.data.id);
						app.user=res.data;
					}).catch(function (e) {
					     keter.handleEx(e);
					});

				   keter.get(this, '/admin/haha').then(function (res) {
                    	  console.log(res.data);
                    }).catch(function (e) {
                          keter.handleEx(e);
                    });

				   keter.get(this, '/user/haha').then(function (res) {
                    	  console.log(res.data);
                    }).catch(function (e) {
                    	  console.log(e.bodyText);
                    });

                    //测试restful get request
				    keter.get(this, '/user/haha/123').then(function (res) {
						console.log(res.data.param);
					}).catch(function (e) {
					   console.log(e);
					});
				},
				methods: {
					regist: function() {
					    keter.post(this, this.postUrl,this.user).then(function (res) {
						    console.log(res.data.success);
					    }).catch(function (e) {
					    });
				    }
					,logout: function() {
					    keter.setToken("");
					    window.location.href="/logout";
				    }
			   }
        });